

extension SExtension on num {
  double get wpx => MyScreenUtil().setWidth(this);
  double get hpx => MyScreenUtil().setHeight(this);
  double get tpx => MyScreenUtil().setSp(this);
}


class MyScreenUtil {
  static late MyScreenUtil _instance;

  static double scaleWidth = 1;
  static double scaleHeight = 1;
  static double scaleText = 1;

  MyScreenUtil._();

  factory MyScreenUtil() {
    return _instance;
  }

  static void init(double width, double height, double text) {
    scaleWidth = width;
    scaleHeight = height;
    scaleText = text;
    _instance = MyScreenUtil._();
  }

  double setWidth(num width) => width * scaleWidth;

  double setHeight(num height) => height * scaleHeight;

  double setSp(num fontSize) => fontSize * scaleText;
}
